package com.lingnan.tijian.service.impl;

import com.lingnan.tijian.domain.Cidetailedreport;
import com.lingnan.tijian.domain.Cireport;
import com.lingnan.tijian.domain.Orders;
import com.lingnan.tijian.dto.ApiResponse;
import com.lingnan.tijian.mapper.CidetailedreportMapper;
import com.lingnan.tijian.mapper.CireportMapper;
import com.lingnan.tijian.service.ifac.ReportService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReportServiceImpl implements ReportService {

    @Autowired
    CireportMapper cireportMapper;
    @Autowired
    CidetailedreportMapper cidetailedreportMapper;

    @Override
    public ApiResponse listReportByOrderId(Orders orders) {
        //返回数据既有大项集合 又有小项集合

        List<Cireport> cireportList=cireportMapper.selectReportByOrderId(orders);

        for(Cireport ci:cireportList){

            List<Cidetailedreport> cidetailedreportList=cidetailedreportMapper.listCidetailedReportByCiidAndOrderId(ci);


            ci.setCidetailedreportList(cidetailedreportList);

        }

        return new ApiResponse(ApiResponse.SUCCESS_STATUS,ApiResponse.SUCCESS_DESC,cireportList);
    }
}
